package com.jy.oms.framework.asyn.task.model;


import com.jy.oms.framework.asyn.task.constants.TaskExecuteStrategyEnum;
import com.jy.oms.framework.asyn.task.constants.TaskQueueTypeEnum;

import java.util.Objects;
import java.util.StringJoiner;

/**
 * 任务组标识
 *
 * @author liuquan
 */
public class TaskGroup {

    private String group;

    private TaskExecuteStrategyEnum taskExecuteStrategy;

    private TaskQueueTypeEnum taskQueueType;

    public TaskGroup(String group, TaskExecuteStrategyEnum taskExecuteStrategy, TaskQueueTypeEnum taskQueueType) {
        this.group = group;
        this.taskExecuteStrategy = taskExecuteStrategy;
        this.taskQueueType = taskQueueType;
    }

    public TaskQueueTypeEnum getTaskQueueType() {
        return taskQueueType;
    }

    public TaskExecuteStrategyEnum getTaskExecuteStrategy() {
        return taskExecuteStrategy;
    }

    public void setTaskExecuteStrategy(TaskExecuteStrategyEnum taskExecuteStrategy) {
        this.taskExecuteStrategy = taskExecuteStrategy;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TaskGroup taskGroup = (TaskGroup) o;
        return Objects.equals(group, taskGroup.group)
                && taskExecuteStrategy == taskGroup.taskExecuteStrategy
                && taskQueueType == taskGroup.taskQueueType;
    }

    @Override
    public int hashCode() {
        return Objects.hash(group, taskExecuteStrategy, taskQueueType);
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", TaskGroup.class.getSimpleName() + "[", "]")
                .add("group='" + group + "'")
                .add("taskExecuteStrategy=" + taskExecuteStrategy)
                .add("taskQueueType=" + taskQueueType)
                .toString();
    }
}
